package com.test.nnooolwdeaer.dialog_wooden;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.constant_wooden.Constant_wooden;
import com.test.nnooolwdeaer.util_wooden.http_wooden.HttpManager_wooden;

import java.util.Objects;

public class NoticeDialog_wooden extends Dialog {

    private final String content;

    public NoticeDialog_wooden(@NonNull Context context, String content) {
        super(context);
        this.content = content;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_notice_wooden);
        initView_wooden();
    }

    @SuppressLint("SetTextI18n")
    private void initView_wooden(){

        try {
            Objects.requireNonNull(getWindow()).setBackgroundDrawableResource(R.color.trans);
            getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            setCancelable(false);
        }catch (Exception e){
            if (Constant_wooden.Debug) e.printStackTrace();
        }

        TextView contentTv = findViewById(R.id.notice_tv_content);
        Button confirmBtn = findViewById(R.id.notice_btn);

        if (!TextUtils.isEmpty(content)) contentTv.setText(content);

        confirmBtn.setOnClickListener(view -> {
            HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint("DIALOG_NOTICE_CONFIRM_CLICK");
            dismiss();
        });

    }

}
